﻿
<script>
    $(function () {        
       // $('#ui_grave_dead_name').autoSearchText({itemHeight: 150, minChar: 1, datafn: getData, fn: alertMsg });
        
    });
    function alertMsg(vl) {
        alert('你将要搜索的关键字是： ' + vl);
    }
    /*加载数据*/
    function getData(val) {
        var arrData = new Array();
        if (val != "") {
            $.ajax({
                type: "post",
                async: false, //控制同步
                url: "ashx/bg_dead.ashx?action=getDeadByName",
                data: "name=" + val,
                dataType: "json",
                cache: false,
                formatItem: function (row, i, max) {//格式化列表中的条目
                    return row.name + "_" + row.relativeName;
                },                
                formatResult: function(row){//选择后文本框显示的值
                    return row.name + "_" + row.relativeName;
                },
                success: function (data) {
                    for (var i = 0; i < data.length; i++) {
                        if (val == data[i].name.substring(0, val.length))                            
                            arrData.push(data[i].name + "|" + data[i].areaName + "|" + data[i].relativeName);
                    }
                },
                Error: function (err) {
                    alert(err);
                }
            });
        }
        return arrData;
    }

</script>
<div style="padding: 15px; overflow: hidden">
    <form id="ui_grave_storeform" method="post" >
        
        <div title="联系人及死者信息" style="padding: 10px">
            <table style="width:95%" class="tableForm">
                <tr>
                    <th >存放位置:</th>
                    <td colspan="3">
                        <input class="easyui-textbox readonly" type="text" disabled ="disabled" name="ui_grave_location" id="ui_grave_location" style="width:95%" />                   
                        <input type="hidden" name="ui_grave_dead_id" id="ui_grave_dead_id" />
                        <input type="hidden" name="ui_grave_id" id="ui_grave_id" />
                        <input type="hidden" name="ui_grave_relative_id" id="ui_grave_relative_id" />
                    </td>
                    
                </tr>
                <tr>
                    <th >存放时间:</th>
                    <td>
                        <input class="easyui-datetimebox" type="text" name="ui_grave_starttime" id="ui_grave_starttime" style="width:95%" />                                           
                    </td>
                    <td colspan="2"><input type="checkbox" name="ui_grave_notsave" id="ui_grave_notsave"  />只登记</td>
                </tr>
                <tr>
                    <td colspan="4" style="background-color:#cccccc">死者信息</td>
                </tr>
                 <tr>   
                     <th style="width:25%">姓名: 
                    </th>
                    <td style="width:25%">
                        <input class="easyui-textbox"  type="text" name="ui_grave_dead_name" id="ui_grave_dead_name" data-options="required:true"  />
                    </td>  
                    <th style="width:25%">身份证:</th>
                    <td style="width:25%">
                        <input class="easyui-textbox" type="text" name="ui_grave_dead_cardno" id="ui_grave_dead_cardno"  data-options="required:false" style="width:150px" />
                    </td>                                                            
                </tr>
                <tr>
                    <th>性别:</th>
                    <td>
                        <select class="easyui-combobox" name="ui_grave_dead_gender" id="ui_grave_dead_gender" data-options="panelHeight:70,editable:false">
                            <option value="男">男</option>
                            <option value="女">女</option>
                            <option value="未知">未知</option>
                        </select>
                    </td>      
                    <th>民族:</th>
                    <td>
                        <input class="easyui-textbox"  type="text" value="汉族"  name="ui_grave_dead_nation" id="ui_grave_dead_nation" />
                    </td>
                </tr>
                <tr>
                    
                <th>所属地区:</th>
                    <td>
                        <input class="easyui-combotree" id="ui_grave_dead_areaId" name="ui_grave_dead_areaId"
                            data-options="url:'ashx/bg_area.ashx?action=getall', lines:true,required:true" />                       
                    </td>
                    <th>组别:</th>
                    <td >
                        <input class="easyui-textbox" id="ui_grave_dead_addr" name="ui_grave_dead_addr" />
                    </td>
                </tr>
                <tr>
                    <th>火化时间:</th>
                    <td>
                        <input class="easyui-datetimebox" id="ui_grave_dead_firetime" name="ui_grave_dead_firetime" data-options="required:false" />
                    </td>  
                    <th>关系:</th>
                    <td >
                        <input class="easyui-textbox" id="ui_grave_relative_relation" name="ui_grave_relative_relation" data-options="required:true" />
                    </td>
                 </tr>
                <tr>
                    <th colspan="1">死者备注：</th>
                    <td colspan="3"><input class="easyui-textbox" id="ui_grave_dead_desc" name="ui_grave_dead_desc"  style="width:90%" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="background-color:#cccccc">联系人信息</td>
                </tr>
                <tr>                    
                    <th>姓名:</th>
                    <td>
                        <input class="easyui-textbox" id="ui_grave_relative_name" name="ui_grave_relative_name" data-options="required:true" />
                    </td>
                    <th>电话:</th>
                    <td>
                        <input class="easyui-textbox" id="ui_grave_relative_tel" name="ui_grave_relative_tel" data-options="required:true" />
                    </td>                    
                </tr>
                <tr>                                        
                    <th>所属地区:</th>
                    <td>
                        <input class="easyui-combotree" id="ui_grave_relative_areaId" name="ui_grave_relative_areaId"
                            data-options="url:'ashx/bg_area.ashx?action=getall', lines:true,required:true" />                       
                    </td>  
                    <th>身份证:</th>
                    <td>
                        <input class="easyui-textbox" type="text" name="ui_grave_relative_cardno" id="ui_grave_relative_cardno"  data-options="required:false" style="width:150px" />
                    </td>      
                </tr>                                                      
            </table>
        </div>
            
     </form>    
</div>
<script>
    $(function () {
        //$('.readonly').attr('disabled', 'disabled');
        //$('.easyui-datetimebox').attr('disabled', '1');
        //$('#ui_grave_dead_cardno').removeAttr('disabled');
        //$('#ui_grave_relative_tel').removeAttr('disabled');


        //$('#ui_grave_dead_cardno').textbox({
        //    prompt: '请输入证件号码查询',
        //    icons: [{
        //        iconCls: 'icon-search',
        //        handler: function (e) {
        //            var cardno = $(e.data.target).textbox('getValue');
        //            getDeadByCardno(cardno);
        //        }
        //    }]
        //});

    });

    function getDeadByCardno(cardno) {
        if (!cardno) {
            $.show_warning("提示", "请输入死者身份证号！");
            return;
        }
        para = {};
        para.action = "getDead";
        para.timespan = new Date().getTime();
        para.cardno = cardno;
        $.ajax({
            url: "ashx/bg_dead.ashx",
            data: para,
            type: "POST",
            dataType: "json",
            success: function (data) {
                var dr = data.msg;
                if (data.success && dr) {
                    $('#ui_grave_dead_id').val(dr.id);
                    $('#ui_grave_dead_cardno').textbox('setValue', dr.cardno);
                    $('#ui_grave_dead_name').textbox('setValue', dr.name);
                    $('#ui_grave_dead_gender').textbox('setValue', dr.gender);
                    $('#ui_grave_dead_nation').textbox('setValue', dr.nationId);
                    $('#ui_grave_dead_deathtime').datetimebox('setValue', dr.deathtime);
                    $('#ui_grave_dead_areaId').textbox('setValue', dr.areaName);
                    if (dr.storeType) {
                        $('#ui_grave_store_type').combobox('setValue', dr.storeType);
                    }
                } else if (dr) {
                    $.show_warning("提示", data.msg);
                } else {
                    $.show_warning("提示", "当前证件号的死者不存在！");
                }
            }
        });
    }
</script>